#include "StompedReality/Core/TypeSystem/TypeSystemImpl.h"
namespace StompedReality
{
namespace type_system
{
TypeSystemImpl::TypeSystemImpl( )
{
}

TypeSystemImpl::~TypeSystemImpl( )
{
  std::cout << "delete type system " << std::endl;
  for ( TypeInfoMap::iterator iter = this->_typeMap.begin( );
        iter != this->_typeMap.end( ); ++iter) {
    delete iter->second;
  }
}

bool TypeSystemImpl::HasType ( StompedReality::TYPE_ID typeID )
{
  return this->_typeMap.find ( typeID ) != this->_typeMap.end( );
}

TypeInfo* TypeSystemImpl::GetType ( StompedReality::TYPE_ID typeID )
{
  return this->_typeMap[ typeID ];
}

TypeInfo* TypeSystemImpl::GetType ( const char* typeName )
{
  return this->_nameInfoMap[StompedReality::hash ( typeName ) ];
}

bool TypeSystemImpl::HasType ( const char* typeName )
{
  return this->_nameInfoMap.find ( StompedReality::hash ( typeName )  ) != this->_nameInfoMap.end( );
}

StompedReality::TYPE_ID TypeSystemImpl::GetTypeID ( const char* typeName )
{
  if ( this->HasType ( typeName ) )
    return this->_nameInfoMap[StompedReality::hash ( typeName ) ]->typeID;
  else
    return 0;
}

}
}
